﻿<phone:PhoneApplicationPage
    x:Class="Conqueror.WP.MatchmakingGamesPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:telerikPrimitives="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Primitives"
    xmlns:viewModel="clr-namespace:Conqueror.WP.ViewModel.Matchmaking"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d">
    
    <phone:PhoneApplicationPage.Resources>
        <viewModel:MatchmakingGamesViewModel x:Key="viewmodel"/>
    </phone:PhoneApplicationPage.Resources>
    
	<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar>
            <shell:ApplicationBarIconButton IconUri="/Image/Icons/appbar.check.png"
                                            Text="join game" Click="JoinGameButton"/>
            <shell:ApplicationBarIconButton IconUri="/Image/Icons/appbar.share.png"
                                            Text="share game" Click="ShareCurrentGameButton"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="browse all open games"
                                              Click="BrowseGamesButton"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
	</phone:PhoneApplicationPage.ApplicationBar>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent"
          DataContext="{StaticResource viewmodel}">
        <phone:Panorama Title="{Binding Title}" ItemsSource="{Binding Results}">
            <phone:Panorama.Background>
                <ImageBrush Stretch="UniformToFill" ImageSource="{Binding MapImageUrl, Source={StaticResource viewmodel}}"
                            Opacity="0.25"/>
            </phone:Panorama.Background>
            <phone:Panorama.TitleTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="12,48,0,-24">
                        <Border Background="{StaticResource PhoneForegroundBrush}"
                                Width="76" Height="76" Margin="-12,0,0,0">
                            <Border.OpacityMask>
                                <ImageBrush ImageSource="/Image/Icons/matchmaker.png"/>
                            </Border.OpacityMask>
                        </Border>
                        <TextBlock Text="{Binding}"
                                   VerticalAlignment="Center"
                                   FontSize="{StaticResource PhoneFontSizeExtraLarge}"/>
                    </StackPanel>
                </DataTemplate>
            </phone:Panorama.TitleTemplate>
            <phone:Panorama.HeaderTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding GameNumber}" Margin="0,0,0,-36"/>
                </DataTemplate>
            </phone:Panorama.HeaderTemplate>
            <phone:Panorama.ItemTemplate>
                <DataTemplate>
                    <ScrollViewer>
                        <StackPanel Margin="12,0,0,0">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Match Challenge" FontWeight="Bold" Foreground="{StaticResource PhoneAccentBrush}"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                <Rectangle VerticalAlignment="Center" Margin="12,0" Height="3"
                                                   Fill="{StaticResource PhoneAccentBrush}" Grid.Column="1"/>
                                <TextBlock Text="{Binding Challenge}" FontWeight="Bold" Grid.Column="2" Foreground="{StaticResource PhoneAccentBrush}"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                            </Grid>
                            <Grid>
                                <TextBlock Text="Initial Troops"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                <TextBlock Text="{Binding InitialTroops}" HorizontalAlignment="Right"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                                   Foreground="{StaticResource PhoneSubtleBrush}"/>
                            </Grid>
                            <Grid>
                                <TextBlock Text="Play Order"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                <TextBlock Text="{Binding PlayOrder}" HorizontalAlignment="Right"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                                   Foreground="{StaticResource PhoneSubtleBrush}"/>
                            </Grid>
                            <Grid>
                                <TextBlock Text="Game Type"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                <TextBlock Text="{Binding GameType}" HorizontalAlignment="Right"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                                   Foreground="{StaticResource PhoneSubtleBrush}"/>
                            </Grid>
                            <Grid>
                                <TextBlock Text="Spoils"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                <TextBlock Text="{Binding Spoils}" HorizontalAlignment="Right"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                                   Foreground="{StaticResource PhoneSubtleBrush}"/>
                            </Grid>
                            <Grid>
                                <TextBlock Text="Reinforcements"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                <TextBlock Text="{Binding Reinforcements}" HorizontalAlignment="Right"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                                   Foreground="{StaticResource PhoneSubtleBrush}"/>
                            </Grid>
                            <Grid>
                                <TextBlock Text="Fog of War"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                <TextBlock Text="{Binding FogOfWar}" HorizontalAlignment="Right"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                                   Foreground="{StaticResource PhoneSubtleBrush}"/>
                            </Grid>
                            <Grid>
                                <TextBlock Text="Trench Warfare"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                <TextBlock Text="{Binding TrenchWarfare}" HorizontalAlignment="Right"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                                   Foreground="{StaticResource PhoneSubtleBrush}"/>
                            </Grid>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Text="Players" FontWeight="Bold"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                <Rectangle VerticalAlignment="Center" Margin="12,0" Height="3"
                                                   Fill="{StaticResource PhoneForegroundBrush}" Grid.Column="1"/>
                                <TextBlock Text="{Binding Players.Count}" FontWeight="Bold" Grid.Column="2"
                                                   FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                            </Grid>
                            <ItemsControl ItemsSource="{Binding Players}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <TextBlock Text="{Binding Username}"
                                                               FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
                                            <TextBlock Text="{Binding Rank}" HorizontalAlignment="Right"
                                                               FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                                               Foreground="{StaticResource PhoneSubtleBrush}"/>
                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </ScrollViewer>
                </DataTemplate>
            </phone:Panorama.ItemTemplate>
        </phone:Panorama>

        <telerikPrimitives:RadBusyIndicator AnimationStyle="AnimationStyle5"
                                            IsRunning="True" ContentPosition="Bottom" Content="Finding Matches"
                                            VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                                            Foreground="{StaticResource PhoneAccentBrush}"/>
    </Grid>

</phone:PhoneApplicationPage>